<%@ page language="java" contentType="text/html; charset=UTF-8"  pageEncoding="UTF-8"%>
<%@ include file="/include/taglibs.jsp"%>
<html>
<head>
  <title>新建流程定义</title>
  <%@ include file="/include/openstyles.jsp"%>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/jquery.validate.min.js"></script>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/validate-methods.js"></script>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/jquery/jquery-form.js"></script>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/input.js"></script>
  <script type="text/javascript" src="${ctx}/assets/admin/LingUI/js/lui.jiantingdiv.js"></script>
  <script type="text/javascript" src="${ctx}/assets/uc/js/common.js"></script>
  <style>
    .help-block{
      margin: 0px!important;
    }
  </style>
</head>
<body>
<div class="row">
  <div class="col-xs-12">
    <div class="space-12"></div>
    <form class="form-horizontal" role="form" id="def_upload_form" enctype="multipart/form-data">
      <div class="tabbable">
        <div class="profile-user-info profile-user-info-striped">
          <div class="profile-info-row">
            <div class="profile-info-name" >流程文件(zip格式)：</div>
            <div class="profile-info-value">
              <input type="file" id="wfFile" name="wfFile"
                     class="col-xs-10 col-sm-8"/>
            </div>
          </div>
        </div>
      </div>
    </form>
  </div>
</div>


<script type="text/javascript">

  var form = "def_upload_form";
  var $form = $("#"+form);

  jQuery(function($) {
    $form.validate({
      rules: {
        'wfFile': {
          required: true
        }
      },

      messages: {
        'wfFile': {
          required: "必须选择文件"
        }
      }
    });

  });

  function formValid(){
    debugger;
    var retObj =new Object();
    var valid = $("#def_upload_form").valid();
    if (valid) {
      $form.ajaxSubmit({
        url : "${ctx}/${frameworkPath}/wf/definition/upload",
        type : "post",
        async :false,
        dataType:'json',
        success : function(message) {
          if (message.success) {
            retObj.text ="保存成功！";
            retObj.state = true;
            retObj.id = message.id;
          } else {
            retObj.text = text;
            retObj.state =false;
          }
        }
      });
    } else {
      return;
    }
    return retObj;
  }
</script>
</body>
</html>